package com.lemurian.bankdata.bean;

import org.hibernate.Criteria;
import org.hibernate.criterion.Order;
import org.springframework.stereotype.Repository;

import com.lemurian.bankdata.bean.base.BaseDaoHibernate;
import com.lemurian.bankdata.lite.logger.BankDataLogger;
import com.lemurian.entity.ActivityTypes;

@Repository
public class ActivityTypesDAO extends BaseDaoHibernate<ActivityTypes>{
	
	private BankDataLogger log = BankDataLogger.getLogger(ActivityTypesDAO.class.getName());
	
	public Integer getLastSequence() {
		int sequence = 0;
		
		Criteria criteria = getSession().createCriteria(ActivityTypes.class);
		
		criteria.addOrder(Order.desc("sequence"));
		criteria.setMaxResults(1);
		
		ActivityTypes activityTypes = (ActivityTypes) criteria.uniqueResult();
		
		if(activityTypes != null) {
			sequence = activityTypes.getSequence() + 1;
		}
		
		return sequence;
	}
}
